package work.mediway.mdm.biz.config;

import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import work.mediway.mdm.biz.interceptor.SqlLogInterceptor;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/3/30
 */
@Slf4j
@Configuration
@RequiredArgsConstructor
public class MybatisSqlPrintAutoConfiguration {

    @Bean
    public String myInterceptor(SqlSessionFactory sqlSessionFactory) {
        log.info(">>>>>>>>>>>>>>>>>>>>>>>> register sqlIntercept");
        sqlSessionFactory.getConfiguration().addInterceptor(new SqlLogInterceptor());
        return "interceptor";
    }

}
